﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Sispe.Entities;
using Sispe.BussinesLogic;
using Microsoft.Practices.Unity;

namespace Sispe.UI
{
    public partial class FrmAdenda : Form
    {
        [Dependency]
        public IAdendaBL adendaBL { get; set; }

        public FrmAdenda()
        {
            InitializeComponent();
            this.BuildUp();
        }

        public ADENDA currentAdenda { get; set; }
        public PROYECTO _currentProyect { get; set; }

        public void cargarProyecto()
        {
            currentAdenda = new ADENDA();
            aDENDABindingSource.AddNew();
            currentAdenda.PROYECTO = _currentProyect;
            aDENDABindingSource.DataSource = currentAdenda;
        }

        private void FrmAdenda_Load(object sender, EventArgs e)
        {
            //CargarDatos();
        }

        //private void CargarDatos()
        //{
        //    aDENDABindingSource.DataSource = adendaBL.GetAllFromAdendas();
        //}

        private void btnEditar_Click(object sender, EventArgs e)
        {
            var updtAdenda = aDENDABindingSource.Current as ADENDA;
            if (updtAdenda != null)
            {
                FrmMttoAdenda frmmttoAdenda = new FrmMttoAdenda();
                frmmttoAdenda.currentAdenda = updtAdenda;
                frmmttoAdenda.Editar();
                frmmttoAdenda.ShowDialog();
            }
            else
            {
                MessageBox.Show("Debe Seleccionar un Adenda", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void radGroupBox1_Click(object sender, EventArgs e)
        {

        }

        public void ObtenerId(string id)
        {
            //this.Show();
            aDENDABindingSource.DataSource = adendaBL.GetFromAdendasByCodigoProy(id);
           
        }

    }
}
